package io.github.jianjianghui.groot.demo;

import cn.hutool.core.lang.Dict;
import io.github.jianjianghui.autolog.spring.SpringAutoLogWeaver;
import io.github.jianjianghui.autolog.spring.annotation.EnableAutoLog;
import io.github.jianjianghui.groot.core.GrootStatusEnum;
import io.github.jianjianghui.groot.core.annotation.Idempotent;
import io.github.jianjianghui.groot.spring.SpringGrootController;
import io.github.jianjianghui.response.v1.Response;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author <a href="https://www.github.com/jianjianghui">Jianghui Jian<a/>
 * @date 2021/8/27 - 17:09
 */
@SpringBootApplication
@RestController
@EnableAutoLog(rest = Response.class, pathPackages = "io.github.jianjianghui.groot")
public class Application {

    static {
        SpringAutoLogWeaver.AUTO_LOG_ORDER = 0;
        SpringGrootController.GROOT_ORDER = 1;
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Idempotent(value = 3000, accessible = {GrootStatusEnum.NONE})
    @GetMapping("/")
    public Response<Dict> hello() {

        return Response.success("success");
    }


    @Idempotent(value = 100000, accessible = {GrootStatusEnum.NONE})
    @GetMapping("/01")
    public Response<String> hello1() {
        throw new RuntimeException("u");
    }
}
